import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/SetStatus")
public class SetStatus extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
       resp.setContentType("text/html;charset=utf8");
       //通过get.getParameter()方法获取GET请求中query string中键值对
       String status=req.getParameter("status");
       //检测是否从请求中获取到status=500键值对
       if(status==null){
           resp.getWriter().write("获取GET请求键值对失败");
           return;
       }
       resp.setStatus(Integer.parseInt(status));
       resp.getWriter().write("状态码设置成工");
    }
}
